<template>
  <base-layout
    :dialog-title="dialogTitle"
    :dialog-visible="dialogVisible"
    @dialog-close="dialogClose"
    :dialogWidth="dialogWidth"
  >
    <template #searchPanel>
      <el-row :gutter="20">
        <search-panel
          @search="search"
          @insert="interestsInfo"
          addTitle="新增职位"
          :showAddButton="true"
          :addPer="authConfig.add"
          :selectPer="authConfig.query"
        >
          <job-shop v-model="form.storeId" placeholder="任职门店" />
          <el-input
            clearable
            style="width: 200px"
            v-model="form.roleName"
            placeholder="职位名称"
          />
        </search-panel>
      </el-row>
    </template>
    <template #contentPanel>
      <data-table
        :value="tableData"
        :has-action="true"
        :total-count="totalCount"
        :table-column-attributes="tableColumnAttributes"
        :width="160"
        :isShowPage="true"
          @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      >
        <template #action="{ row }">
          <i
            class="el-icon-edit"
            title="编辑"
            style="cursor: pointer"
            v-permission="authConfig.edit"
            @click="interestsInfo(row)"
          ></i>
          <i
            class="el-icon-delete"
            title="删除"
            style="color: red; margin-left: 20px; cursor: pointer"
            v-permission="authConfig.del"
            @click="handleDataDelete(row)"
          ></i>
        </template>
      </data-table>
      <!--工具条-->
    </template>
  </base-layout>
</template>

<script>
import { dataList, deleteData } from '@/api/after-sale/systemManage/role'
import baseMixin from '@/mixins/base'
import ElFormItem from 'element-ui/packages/form/src/form-item.vue'
import ElRow from 'element-ui/packages/row/src/row'
import ElCol from 'element-ui/packages/col/src/col'
import { parseTimeToYMDHMS } from '@/utils'

export default {
  components: {
    ElCol,
    ElRow,
    ElFormItem,
  },
  mixins: [
    baseMixin({
      idName: 'id',
      findData: dataList,
      deleteData: deleteData,
      dataName: ['content', 'totalRecords'],
      isAdd: false,
    }),
  ],
  data() {
    return {
      authConfig: {
        query: 'SystemRole:page',
        add: 'SystemRole:create',
        edit: 'SystemRole:update',
        del: 'SystemRole:delete',
      },
      dialogVisible: false,
      dict: [],
      dialogWidth: '700px',
      service: {},
      isAdd: false,
      //查询条件
      form: {
        roleName: '', //职位名称
        storeId: '', //门店id
      },
      //table字段
      tableColumnAttributes: [
        { name: '职位所属门店', value: 'storeName', type: 'text' },
        { name: '职位名称', value: 'roleName', type: 'text' },
        { name: '任职数', value: 'activeStaff', type: 'text' },
        { name: '职位权限', value: 'roleAuth', type: 'text' },
        { name: '备注', value: 'roleDesc', type: 'text' },
        { name: '创建时间', value: 'createTime', type: 'text' },
      ],
    }
  },
  methods: {
    search() {
      this.searchOptions = {
        roleName: this.form.roleName,
        storeId: this.form.storeId,
      }
      this.currentPage = 1
      this.setTableData()
    },
    interestsInfo(row) {
      this.$router.push({
        path: '/systemManage/roleInfo',
        query: {
          id: row?row.id:null,
        },
      })
    },
  },
  mounted(){
    
  }
}
</script>

